<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue透传,插槽</title>
    <style>
        .father {
            background-color: antiquewhite;
            width: 500px;
            height: 300px;
        }

        .son {
            color: blue;
            height: 200px;
            width: 200px;
        }
        .con{
            width: 300px;
        }
    </style>
</head>

<body>
    <div id="app">
        <father></father>
        <!-- <son></son> -->
    </div>
    <script src="./vue.global.js"></script>
    <script>
        const { createApp } = Vue;
        const app = createApp({});
        app.component("father", {
            template: `<div :=attrs>
                <h3>来自父组件的问候</h3>
                <son class='father' @click='output'/>
                <son>
                    <template v-slot:sl>
                    <p>父组件的插入</p>
                    </template>
                </son>
            </div>`,
            methods: {
                output() {
                    console.log(1)
                }
            }, props: ['attrs'],
        })
        app.component("son", {
            template: `<div class='con'>
                <div class='son' @click='input'>son{{digit}}</div>
                <slot name='sl'></slot>
                </div>`,
            methods: {
                input() {
                    console.log(2);
                    this.digit++;
                }
            },
            data() {
                return { digit: 0 }
            },
        })
        app.mount('#app');
    </script>
</body>

</html>